package com.zhouxiaoge.泛型.泛型类;

import com.zhouxiaoge.泛型.Pair;

/**
 * @author 周明阳
 * mail:gqzmy@outlook.com
 * 时间:2018-05-04 16:23
 */

public class ArrayAlg {

    public static Pair<String> minmax(String[] a) {
        if (a == null || a.length == 0) {
            return null;
        }
        String min = a[0];
        String max = a[0];
        for (String s : a) {
            if (min.compareTo(s) > 0) {
                min = s;
            }
            if (max.compareTo(s) < 0) {
                max = s;
            }
        }
        return new Pair<>(min, max);
    }

}
